package com.example.hdwx.myapplication.adapter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;


import com.example.hdwx.myapplication.R;
import com.example.hdwx.myapplication.eneity.daydaycook_eneitys.Daydaycook_everyday_eneity;
import com.example.hdwx.myapplication.untils.ImageShow;

import java.util.List;

/**
 * Created by hdwx on 2017/2/13.
 */

public class Daydaycook_item_adapter extends RecyclerView.Adapter<Daydaycook_item_adapter.ViewHolder> {
    List<Daydaycook_everyday_eneity> item_list;
    Context item_context;
    public Daydaycook_item_adapter (Context context,List<Daydaycook_everyday_eneity> list){
        this.item_context=context;
        this.item_list=list;
    }

    @Override
    public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view= LayoutInflater.from(parent.getContext()).inflate(R.layout.daydaycook_item_recycle_view,parent,false);
        return new ViewHolder(view);
    }

    @Override
    public void onBindViewHolder(ViewHolder holder, int position) {
        holder.num.setText(item_list.get(position).getNum());
        holder.name.setText(item_list.get(position).getName());
        holder.description.setText(item_list.get(position).getDescription());
        new ImageShow().image_show(item_context,item_list.get(position).getImg_url(),holder.image_url);
    }

    @Override
    public int getItemCount() {
       return item_list.size();
    }

    class ViewHolder extends RecyclerView.ViewHolder {
        ImageView image_url,video_url;
        TextView name ,description,num;
        public ViewHolder(View itemView) {
            super(itemView);
            image_url= (ImageView) itemView.findViewById(R.id.daydaycook_item_recycle_image);
            name= (TextView) itemView.findViewById(R.id.daydaycook_item_recycle_title);
            description= (TextView) itemView.findViewById(R.id.daydaycook_item_recycle_text);
            num= (TextView) itemView.findViewById(R.id.daydaycook_item_recycle_num);
        }
    }
}
